<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
    function createTable(row,col,width,height,bdcolor){
        var tableStr="";
        tableStr+=("<table style='width:"+width+"px;height:"+height+"px;border-collapse: collapse'>");
        for(var i=0; i<row; i++){                             //指定外层循环
            tableStr+=("<tr>");
            for(var j=0; j<col; j++){                          //指定内层循环
                tableStr+=("<td style='border:1px solid "+bdcolor+"'></td>");
            }
            tableStr+=("</tr>");
        }
        tableStr+=("</table>");
        return tableStr;
    }
    document.write(createTable(4,6,500,160,"green"));    //调用函数并传递参数
</script>

</body>
</html>
